ContextCompat

open class ContextCompat(source)

Helper for accessing features in Context.

Inheritors

Types

Properties

Link copied to clipboard
Flag for registerReceiver: The receiver can receive broadcasts from other Apps.
Link copied to clipboard
Flag for registerReceiver: The receiver cannot receive broadcasts from other Apps.
Link copied to clipboard
Flag for registerReceiver: The receiver can receive broadcasts from Instant Apps.

Functions

Link copied to clipboard
open fun checkSelfPermission(@NonNull context: Context, @NonNull permission: String): Int
Determine whether you have been granted a particular permission.
Link copied to clipboard
open fun createAttributionContext(@NonNull context: Context, @Nullable attributionTag: String): Context
Return a new Context object for the current Context but attribute to a different tag.
Link copied to clipboard
Return a new Context object for the current Context but whose storage APIs are backed by device-protected storage.
Link copied to clipboard
Attribution can be used in complex apps to logically separate parts of the app.
Link copied to clipboard
Returns the absolute path to the application specific cache directory on the filesystem designed for storing cached code.
Link copied to clipboard
open fun getColor(@NonNull context: Context, @ColorRes id: Int): Int
Returns a color associated with a particular resource ID Starting in M, the returned color will be styled for the specified Context's theme.
Link copied to clipboard
Returns a color state list associated with a particular resource ID.
Link copied to clipboard
Gets the context which respects the per-app locales locale.
Link copied to clipboard
open fun getDataDir(@NonNull context: Context): File
Returns the absolute path to the directory on the filesystem where all private files belonging to this app are stored.
Link copied to clipboard
Get the display this context is associated with or the default display as the fallback if the context is not associated with any Display.
Link copied to clipboard
Returns a drawable object associated with a particular resource ID.
Link copied to clipboard
Returns absolute paths to application-specific directories on all external storage devices where the application can place cache files it owns.
Link copied to clipboard
Returns absolute paths to application-specific directories on all external storage devices where the application can place persistent files it owns.
Link copied to clipboard
Return an Executor that will run enqueued tasks on the main thread associated with this context.
Link copied to clipboard
Returns the absolute path to the directory on the filesystem similar to getFilesDir.
Link copied to clipboard
open fun getObbDirs(@NonNull context: Context): Array<File>
Returns absolute paths to application-specific directories on all external storage devices where the application's OBB files (if there are any) can be found.
Link copied to clipboard
open fun getString(@NonNull context: Context, resId: Int): String
Gets the resource string that also respects the per-app locales.
Link copied to clipboard
open fun <T> getSystemService(@NonNull context: Context, @NonNull serviceClass: Class<T>): T
Return the handle to a system-level service by class.
Link copied to clipboard
open fun getSystemServiceName(@NonNull context: Context, @NonNull serviceClass: Class<out Any>): String
Gets the name of the system-level service that is represented by the specified class.
Link copied to clipboard
Indicates if the storage APIs of this Context are backed by device-encrypted storage.
Link copied to clipboard
open fun registerReceiver(@NonNull context: Context, @Nullable receiver: BroadcastReceiver, @NonNull filter: IntentFilter, flags: Int): Intent
open fun registerReceiver(@NonNull context: Context, @Nullable receiver: BroadcastReceiver, @NonNull filter: IntentFilter, @Nullable broadcastPermission: String, @Nullable scheduler: Handler, flags: Int): Intent
Register a broadcast receiver.
Link copied to clipboard
open fun startActivities(@NonNull context: Context, @NonNull intents: Array<Intent>): Boolean
open fun startActivities(@NonNull context: Context, @NonNull intents: Array<Intent>, @Nullable options: Bundle): Boolean
Start a set of activities as a synthesized task stack, if able.
Link copied to clipboard
open fun startActivity(@NonNull context: Context, @NonNull intent: Intent, @Nullable options: Bundle)
Start an activity with additional launch information, if able.
Link copied to clipboard
open fun startForegroundService(@NonNull context: Context, @NonNull intent: Intent)
startForegroundService() was introduced in O, just call startService for before O.